import ToolButton from "./ToolButton.vue"
import ToolButtonDown from "./ToolbuttonDown.vue"
import ToolButtonGroup from "./ToolButtonGroup.vue"

export function handleCommand(vm, meta) {
  const { command } = meta;
  const eArgs = { command, meta };
  vm.execute(meta.command, eArgs);
}

export function hasChildren(item) {
  return item.children
    && item.children.length > 0;
}

export function selComps(item) {
  if (item.control == "btnGroup") {
    return ToolButtonGroup;
  } else {
    if (hasChildren(item)) {
      return ToolButtonDown;
    } else {
      return ToolButton;
    }
  }
}